using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace MyMvc.Model.Models.Mapping
{
    public class MessageMap : EntityTypeConfiguration<Message>
    {
        public MessageMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.Topic)
                .IsRequired();

            this.Property(t => t.Position)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.People)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Mail)
                .IsRequired()
                .HasMaxLength(200);

            this.Property(t => t.Website)
                .IsRequired()
                .HasMaxLength(150);

            this.Property(t => t.Words)
                .IsRequired();

            // Table & Column Mappings
            this.ToTable("Messages");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.Topic).HasColumnName("Topic");
            this.Property(t => t.Position).HasColumnName("Position");
            this.Property(t => t.People).HasColumnName("People");
            this.Property(t => t.Mail).HasColumnName("Mail");
            this.Property(t => t.Phone).HasColumnName("Phone");
            this.Property(t => t.Website).HasColumnName("Website");
            this.Property(t => t.Words).HasColumnName("Words");
            this.Property(t => t.Type).HasColumnName("Type");
        }
    }
}
